using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;

namespace MapDrawer
{
    public class Coordinate
    {
        public double Longitude { get; set; }
        public double Latitude { get; set; }

        public Coordinate ()
        { }

        public Coordinate(double la, double lo)
        {
            Longitude = lo;
            Latitude = la;
        }

        public void TranslateOnMap(double minLat, double minLon, double maxLat, double maxLon)
        {
	        Latitude = TranslateToRange(Latitude, minLat, maxLat);
	        Longitude = TranslateToRange(Longitude, minLon, maxLon);
        }

		/// <summary>
		/// Transform a point in range [min, max] to the range [-1, 1]
		/// </summary>
	    private double TranslateToRange(double value, double min, double max)
		{

		    //value -= min;
		    //value *= 2/max;
		    //value -= 1;

			double interval = max - min;
			double point = value - min;
			double pointRescaled = point*2/interval;
			double pointTranslated = pointRescaled - 1;

			return pointTranslated;
		}
    }
}